<template>
  <div class="assessment-change-plan-container">
    <div class="my-form-container" style="width:100%;margin:0">
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">课程名称：</div>
          <div class="my-form-item-value">{{tableData.coursename}}</div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">课程编号：</div>
          <div class="my-form-item-value">{{tableData.coursenumber}}</div>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">课程类型：</div>
          <div class="my-form-item-value">{{tableData.coursetype}}</div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">学 时：</div>
          <div class="my-form-item-value">{{tableData.classhour}}</div>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">学 分：</div>
          <div class="my-form-item-value">{{tableData.credithour}}</div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">培养层次：</div>
          <div class="my-form-item-value">{{tableData.traininglevel}}</div>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">分 制：</div>
          <div class="my-form-item-value">
            <span>{{tableData.scoretypecoder}}</span>
            <span class="red-tip">变更为</span>
            <el-select
              v-model="a1"
              placeholder="请选择"
              class="bk"
              @input="handleChangeZY"
              clearable
              style="width:99px"
            >
              <el-option
                v-for="item in scoreList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
            <!-- <el-input size="small" style="width: 99px" v-model="a1"></el-input> -->
          </div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">课程考核一票否决：</div>
          <div class="my-form-item-value">{{tableData.oneticketveto}}</div>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">授课对象：</div>
          <div class="my-form-item-value">{{tableData.professionaldivisions}}</div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">人 数：</div>
          <div class="my-form-item-value">{{tableData.totalnumber}}人</div>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">开课教研室：</div>
          <div class="my-form-item-value">{{tableData.teachingandresearchsection}}</div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">教学班数：</div>
          <div class="my-form-item-value">{{tableData.classes}}</div>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">课程负责人：</div>
          <div class="my-form-item-value">{{tableData.coursemanager}}</div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">授课教员：</div>
          <div class="my-form-item-value">{{tableData.teachingfaculty}}</div>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">课下作业成绩所占比例：</div>
          <div class="my-form-item-value">
            <span>{{tableData.usualscoreratealter}}%</span>
            <span class="red-tip">变更为</span>
            <el-input size="small" style="width: 99px" v-model="a2"></el-input> %
          </div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">课堂测试成绩所占比例：</div>
          <div class="my-form-item-value">
            <span>{{tableData.examscoreratealter}}%</span>
            <span class="red-tip">变更为</span>
            <el-input size="small" style="width: 99px" v-model="a3"></el-input> %
          </div>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">期中考试成绩所占比例：</div>
          <div class="my-form-item-value">
            <span>{{tableData.midtermscoreratealter}}%</span>
            <span class="red-tip">变更为</span>
            <el-input size="small" style="width: 99px" v-model="a4"></el-input> %
          </div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">期末考受成绩所占比例：</div>
          <div class="my-form-item-value">
            <span>{{tableData.experimentscoreratealter}}%</span>
            <span class="red-tip">变更为</span>
            <el-input size="small" style="width: 99px" v-model="a5"></el-input> %
          </div>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">期末考试方式：</div>
          <div class="my-form-item-value">
            <span>{{tableData.oldfinalexaminationalter}}</span>
            <span class="red-tip">变更为</span>
            <el-select
              v-model="selectPaperMethod"
              placeholder="请选择"
              size="small"
              style="width: 187px"
            >
              <el-option
                v-for="item in finalexamList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </div>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">场地需求：</div>
          <div class="my-form-item-value">
            <span>{{tableData.oldsitudemandalter}}</span>
            <span class="red-tip">变更为</span>
            <el-select
              v-model="selectClassRoom"
              placeholder="请选择"
              size="small"
              style="width: 187px"
            >
              <el-option
                v-for="(item,index) in classrooms"
                :key="index"
                :label="item.cdmc"
                :value="item.cdmc"
              >
              </el-option>
            </el-select>
          </div>
        </el-col>
      </el-row>
      <el-row class="my-form-item" style="height: 278px; border: none">
        <el-col :span="24">
          <div class="my-form-item-label">考核设计：</div>
          <div class="my-form-item-value assessment-design">
            <el-input
              type="textarea"
              :rows="10"
              style="width: 600px"
              v-model="tableData.oldassessmentdesignalter"
              disabled="true"
            ></el-input>
            <span class="red-tip">变更为</span>
            <el-input
              type="textarea"
              v-model="design"
              :rows="10"
              style="width: 600px"
              placeholder="请输入内容"
            ></el-input>
          </div>
        </el-col>
      </el-row>
    </div>
    <div class="button-group" style="margin:30px">
      <el-button
        class="btn"
        type="text"
        @click="tgupdate"
        >保 存</el-button
      >
      <el-button
        class="btn"
        type="text"
        @click="tgupdaters"
        >保存并提交</el-button
      >
    </div>
  </div>
</template>

<script>
import {add, getDetail,tgupdate, insertCourseModify} from "../../../api/courseExame/courseExa";
import { getStore } from '@/util/store.js'
import { getPlaceInfoList} from "@/api/courseAchievement/entryResults";

export default {
  data() {
    return {
      scoreList: [
        {
          value: "百分制",
          label: "百分制"
        },
        {
          value: "四分制",
          label: "四分制"
        },
        {
          value: "五分制",
          label: "五分制"
        },
        {
          value: "二分制",
          label: "二分制"
        }
      ],
      design: undefined,
      selectClassRoom: undefined,
      classrooms: [],
      selectPaperMethod: undefined,
      a1: undefined,
      a2: undefined,
      a3: undefined,
      a4: undefined,
      a5: undefined,
      tableData:[],
      roleId:'',
      finalexamList: [
        {
          value: "笔试闭卷",
          label: "笔试闭卷"
        },
        {
          value: "笔试开卷",
          label: "笔试开卷"
        },
        {
          value: "口试",
          label: "口试"
        },
        {
          value: "机试",
          label: "机试"
        },
        {
          value: "实操",
          label: "实操"
        },
        {
          value: "课程论文",
          label: "课程论文"
        },
        {
          value: "其他",
          label: "其他"
        }
      ],
      cdmc:'',
      ssjzw:'',
      zwsTop:'',
      zwsLow:''
    };
  },
  created() {
    this.tableData = this.$route.query.item;
    const userInfo = getStore({
      name: "userInfo",
      debug: true,
    }) || {}
    this.roleId = userInfo.content.role_id;
    console.log(this.roleId)
    this.getPlaceInfo();
    //this.getOldPlanDetail();
  },
  methods: {
    getPlaceInfo(){ 
      getPlaceInfoList(this.cdmc,this.ssjzw,this.zwsTop,this.zwsLow).then(res=>{
        if(res.data.code == 200){
          this.classrooms = res.data.data
        }
      })
    },
    getOldPlanDetail(){
      getDetail(this.$route.query.planid).then(res => {
        this.tableData = res.data.data;
        console.log("输出",res.data.data);
      })
    },
    addApply(pid){
      let obj ={
        checkplanid: pid,
        scoretypecoder: this.a1,
        usualscoreratealter: this.a2,
        examscoreratealter: this.a3,
        midtermscoreratealter: this.a4,
        experimentscoreratealter: this.a5,
        finalexaminationalter: this.selectPaperMethod,
        situdemandalter: this.selectClassRoom,
        assessmentdesignalter: this.design,
      }
      console.log("对象",obj);
      add(obj).then(res =>{
        // this.open('此操作将保存该文件, 是否继续?');
        this.$router.push("/admin/planManagement/planega");
      })
    },
    applySubmit(pid){
      let obj ={
        checkplanid: pid,
        scoretypecoder: this.a1,
        usualscoreratealter: this.a2,
        examscoreratealter: this.a3,
        midtermscoreratealter: this.a4,
        experimentscoreratealter: this.a5,
        finalexaminationalter: this.selectPaperMethod,
        situdemandalter: this.selectClassRoom,
        assessmentdesignalter: this.design,
        modifystrtus: "2",
        modetalstatus: "1"
      }
      console.log("对象",obj);
      add(obj).then(res =>{
        // this.open('此操作将保存该文件, 是否继续?');
        this.$router.push("/teacher/assessment/plan");
      })
    },
     tgupdate(){
      console.log(this.tableData.modifyid,"111")
      let obj ={
        modifyid: this.tableData.modifyid,
        scoretypecoder: this.a1,
        usualscoreratealter: this.a2,
        examscoreratealter: this.a3,
        midtermscoreratealter: this.a4,
        experimentscoreratealter: this.a5,
        finalexaminationalter: this.selectPaperMethod,
        situdemandalter: this.selectClassRoom,
        assessmentdesignalter: this.design,

        scoretypecode: this.a1, 
        usualscorerate: this.a2, 
        examscorerate: this.a3, 
        midtermscorerate: this.a4, 
        experimentscorerate: this.a5, 
        oldfinalexaminationalter: this.selectPaperMethod,
         oldsitudemandalter: this.selectClassRoom, 
         oldassessmentdesignalter: this.design,
        
      }
      tgupdate(obj).then(res =>{
        if (res.data.code == 200){
          this.$message.success("修改成功")
          if(this.roleId === '1490880658945843202'){
            this.$router.push("/director/planManagement/planega");
          } else if(this.roleId === '1490859421955674114'){
            this.$router.push("/admin/planManagement/planega");
          }
        } else {
          this.$message.success("保存失败！")
        }
        // this.open('此操作将保存该文件, 是否继续?');
        // this.$router.push("/teacher/assessment/plan");
      })
    },
    tgupdaters(){
      console.log(this.tableData.modifyid,"111")
      let obj ={
        modifyid: this.tableData.modifyid,
        scoretypecoder: this.a1,
        usualscoreratealter: this.a2,
        examscoreratealter: this.a3,
        midtermscoreratealter: this.a4,
        experimentscoreratealter: this.a5,
        finalexaminationalter: this.selectPaperMethod,
        situdemandalter: this.selectClassRoom,
        assessmentdesignalter: this.design,
        scoretypecode: this.a1, 
        usualscorerate: this.a2, 
        examscorerate: this.a3, 
        midtermscorerate: this.a4, 
        experimentscorerate: this.a5, 
        oldfinalexaminationalter: this.selectPaperMethod,
        oldsitudemandalter: this.selectClassRoom, 
        oldassessmentdesignalter: this.design,
      }
      tgupdate(obj).then(res =>{
        if (res.data.code == 200){
          this.$message.success("保存成功！")
          if(this.roleId === '1490880658945843202'){
            this.$router.push("/director/planManagement/planega");
          } else if(this.roleId === '1490859421955674114'){
            this.$router.push("/admin/planManagement/planega");
          }
        } else {
          this.$message.success("保存失败！")
        }
        // this.open('此操作将保存该文件, 是否继续?');
        // this.$router.push("/teacher/assessment/plan");
      })
    },
	  open(str) {
        this.$confirm(str, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$message({
            type: 'success',
            message: '保存成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消保存'
          });
        });
      }

  },
};
</script>
<style lang="less" scoped>
.assessment-change-plan-container {
  .assessment-design {
    .el-textarea__inner {
      resize: none;
      font-size: 16px;
      color: rgba(0, 76, 167, 1);
    }
  }
}
</style>
<style scoped lang="less">
.assessment-change-plan-container {
  .red-tip {
    color: red;
    margin: 0 14px;
  }
  .assessment-design {
    padding: 13px 9px !important;
    .el-textarea__inner {
      resize: none;
    }
    .red-tip {
      margin: 0 7px;
      display: inline-block;
      vertical-align: 105px;
    }
  }
  .button-group {
    text-align: center;
    .btn {
      display: inline-block;
      font-size: 18px;
      padding: 6px 22px;
      border-radius: 6px;
      &:nth-child(1) {
        color: #f3b815;
        border: 1px solid #f3b815;
        background: #fff6ef;
        margin-right: 139px;
      }
      &:nth-child(2) {
        color: #02c86c;
        border: 1px solid #02c86c;
        background: #f1fff8;
      }
    }
  }
}
</style>
